package com.example.common.entity;

import jakarta.persistence.*;
import lombok.Data;

import java.math.BigInteger;


@Entity
@Table(name = "sys_user_roles")
@Data
public class SysUserRoles {
    
    @EmbeddedId
    private SysUserRolesId id;
    
    @ManyToOne
    @MapsId("userId")
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    private SysUser sysUser;
    
    @ManyToOne
    @MapsId("roleId")
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    private SysRole sysRole;
    
    @Transient
    public BigInteger getUserId() {
        return sysUser.getUserId();
    }
    
    public void setUserId(BigInteger userId) {
        SysUser user = new SysUser();
        user.setUserId(userId);
        this.sysUser = user;
    }
    
    @Transient
    public BigInteger getRoleId() {
        return sysRole.getRoleId();
    }
    
    public void setRoleId(BigInteger roleId) {
        SysRole role = new SysRole();
        role.setRoleId(roleId);
        this.sysRole = role;
    }
    
}
